#!/bin/bash -n

( 

owner=$(./ttyowner);

cd support/base16-streamer; 

[[ $1 = remove ]] && {

    bash.report "Removing hexstream" rm /bin/hexstream;
    bash.report "Removing streamhex" rm /bin/hexstream;    
    return;
    
} || {

    su $owner && echo && bash.report "Installing base16-streamer binaries" \
    mv -f -t /bin hexstream streamhex;
    
} <<<". bash-masters;

bash.report 'Compiling hexstream' \
    gcc -fno-strict-aliasing -O3 -o hexstream hexstream.c || exit 1;

bash.report 'Compiling streamhex' \
    gcc -fno-strict-aliasing -O3 -o streamhex streamhex.c || exit 1;

bash.report 'Compacting binaries' \
    strip --strip-unneeded hexstream streamhex || exit 1;

";)
